package com.mit.web.business.remote
{
	import com.mit.web.util.FlexSession;
	import com.mit.web.vo.sys.UserVO;
	
	import mx.rpc.remoting.RemoteObject;

	public class BaseService
	{
		private var dest:String;
		private var ivk:IInvoker;
		private const ignoreSecurityMethods:Array = ["retrieveUserByNamePwd"];
		public function BaseService(destination:String)
		{
			dest = destination;
		}
		
		protected function get destination():String{
			return dest;
		}
		
		protected function get invoker():IInvoker{
			if(!ivk)
				ivk = new RemoteObjectInvoker(dest);
			return ivk;
		} 
		
		protected function set invoker(i:IInvoker):void{
			ivk = i;
		}
		
		protected function invoke(method:String, ...args):IInvokeResponder{

			//追加UserVO在参数尾部
			if(ignoreSecurityMethods.indexOf(method) > -1){
				args.push(new UserVO());
			}else{
				args.push(FlexSession.currentUser);
			}
			return this.invoker.invoke(method, args);
		}
	}
}